package com.heyige.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("member_orders")
public class MemberOrder {
    
    @TableId(type = IdType.AUTO)
    private Long id;
    
    @TableField("user_id")
    private Long userId;
    
    @TableField("member_level_id")
    private Long memberLevelId;
    
    @TableField("order_no")
    private String orderNo;
    
    @TableField("status")
    private String status = OrderStatus.PENDING.name();
    
    @TableField("payment_method")
    private String paymentMethod;
    
    @TableField("payment_no")
    private String paymentNo;
    
    @TableField("amount")
    private Double amount = 0.0;
    
    @TableField("duration_days")
    private Integer durationDays;
    
    @TableField("start_time")
    private LocalDateTime startTime;
    
    @TableField("end_time")
    private LocalDateTime endTime;
    
    @TableField("paid_time")
    private LocalDateTime paidTime;
    
    @TableField("cancel_time")
    private LocalDateTime cancelTime;
    
    @TableField("refund_time")
    private LocalDateTime refundTime;
    
    @TableField("remark")
    private String remark;
    
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;
    
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;
    
    public enum OrderStatus {
        PENDING,       // 待支付
        PAID,          // 已支付
        CANCELLED,     // 已取消
        REFUNDED,      // 已退款
        FAILED         // 支付失败
    }
}